import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:finance_app/src/widgets/select/mixin/radio_mixin.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class CreditNoteNumberCheckBox = CreditNoteNumberRadio with CheckBoxMixin;

class CreditNoteNumberRadio extends StatelessWidget with RadioMixin {
  final bool isSelect;
  final String title;
  final double minWidth;
  final String creditNoteNo;
  final String issueDate;
  final double amount;
  final String currency;
  final String status;

  const CreditNoteNumberRadio(
      {Key key,
      this.isSelect = false,
      this.title,
      this.minWidth,
      this.creditNoteNo,
      this.issueDate,
      this.amount,
      this.currency,
      this.status})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.only(
        left: getDp(29),
        right: getDp(19),
        top: getDp(23),
        bottom: getDp(23),
      ),
      decoration: BoxDecoration(
          color: isSelect == true ? aceSelectBackgroundColor : Colors.white,
          border: Border(
              bottom: BorderSide(
            color: aceWhiteGreyColor,
            width: getDp(0.5),
          ))),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          buildSelectWidget,
          SizedBox(
            width: getDp(24),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 1,
                  ),
                ),
                AppSpaces.h6,
                Text(
                  'Credit Note No: #$creditNoteNo',
                  style: TextStyle(
                    color: aceDarkGrayColor,
                    fontSize: getSp(14),
                    fontWeight: FontWeight.w400,
                    height: 1,
                  ),
                ),
                AppSpaces.h6,
                Text(
                  'Issue Date: $issueDate',
                  style: TextStyle(
                    color: aceDarkGrayColor,
                    fontSize: getSp(14),
                    fontWeight: FontWeight.w400,
                    height: 1,
                  ),
                ),
              ],
            ),
          ),
          if (currency != null && amount != null)
            Padding(
              padding: EdgeInsets.only(right: getDp(19)),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  if (status != null)
                    Container(
                        margin: EdgeInsets.only(
                          bottom: getDp(10),
                        ),
                        child: RedTagWidget(
                          content: status,
                        )),
                  Text.rich(
                    TextSpan(
                        text: CashUtils.operation(amount),
                        style: TextStyle(
                          fontSize: getSp(16),
                          color: CashUtils.getColor(amount),
                          fontWeight: FontWeight.bold,
                          height: 14 / 12,
                        ),
                        children: [
                          TextSpan(
                              text:
                                  ' $currency ${CashUtils.ignoreFormatCashAmount(amount)}',
                              style: TextStyle(
                                color: aceBlackColor,
                                fontSize: getSp(16),
                                fontWeight: FontWeight.w700,
                                height: 14 / 16,
                              )),
                        ]),
                  ),
                ],
              ),
            )
        ],
      ),
    );
  }
}
